var typeClass=$("#typeClass").val();
if(typeClass==0){
	$("#buttonClass").html("立即反馈回复");
	$("#aClass").html("反馈回复");
	$.post("findmessage.do?id="+$("#idClass").val(),function(data){
		if(data.type==0){
			layer.msg("产品不存在请从新添加");
		}else{
			$("#cName").val(data.data[0].userId);
			$("#cDescribe").val(data.data[0].userName);
			$("#cNum").html(data.data[0].mContent);
			$("#mPhoto").html(data.data[0].mPhoto);
		}
	},"json")
}
layui.use('form', function(){
	var form = layui.form;
	//监听提交
	form.on('submit(formDemo)', function(data){

//		if(data.field.fileupload=""){
//			alert("选择回复图片");
//			return;
//		}
		if(data.field.cNum=""){
			alert("输入回复内容");
			return;
		}
		$.post("findmessageUpdate.do",{
//			cPhoto:$("#fileupload").val(),
			cNum:data.field.username,
			id:$("#idClass").val()
			},function(res){
				if(res.type==1){
					 layer.alert("回复成功", {icon: 6},function () {
	                    // 获得frame索引
	                    window.parent.location.reload();
	                    var index = parent.layer.getFrameIndex(window.name);
	                    //关闭当前frame
	                    window.location.reload();
	                    parent.layer.close(index);
	                }); 
				  }else{
						 layer.msg("操作失败", {
							area : [ '300px', '200px' ]
						});
						 setTimeout(function(){
			                  //刷新
			                  location.reload();
			              },1000);
				  }
		},"json")			  
		return false;
	});
});
layui.use('upload', function(){
	  var $ = layui.jquery
	  ,upload = layui.upload;
	  
	  
	  //多图片上传
	  upload.render({
	    elem: '#test2'
	    ,url: 'UploadServlet.do'
	    ,multiple: true
	    ,before: function(obj){
	      //预读本地文件示例，不支持ie8
	      obj.preview(function(index, file, result){
	        $('#demo2').append('<img src="'+ result +'" alt="'+ file.name +'" style="width: 100px;height: 100px;" class="layui-upload-img">')
	      });
	    }
	    ,done: function(res){
	    	console.log(res);
	   	 if(res.type == 1){ //上传成功
	   		 var demoText = $('#demoText');
	   		  demoText.html('<span style="color: #FF5722;">上传成功</span>');
	   		  var a=$("#fileupload").val();
	   		  if(a==''){
	   			 $("#fileupload").val(res.data.data.src);
	   		  }else{
	   			 $("#fileupload").val(a+","+res.data.data.src);
	   		  }
	   		 
	     }
	    }
	  });
	});